package mcsm.GUI.LeftPanel;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.ImageIcon;

import mcsm.GUI.LabelButton;
import mcsm.GUI.MyFrame;
import mcsm.GUI.RightPanel.RightPanel;
import mcsm.GUI.RightPanel.RightPanelFactory;
import mcsm.Model.Person;

public class GeneralManagerLeftPanel extends FunctionLeftPanel{
	GeneralManagerLeftPanel(Person gm, int width, int height, MyFrame frame) {
		super(gm, width, height, frame);
	}
	
	private class GeneralManagerUpPanel extends FunctionUpPanel {
		public GeneralManagerUpPanel(int width, int height) {
			super(width, height);	
		}
	}
	
	private class GeneralManagerDownPanel extends FunctionDownPanel {
		public GeneralManagerDownPanel(int width, int height) {
			super(width, height);
			this.setButtons(4);
		}
		
		@Override
		protected int setOtherLabelsAndSetY() {
			ImageIcon goods_nor = new ImageIcon(this.getClass().getResource("/SEED/icon/goods_nor.gif"));
			ImageIcon goods_sel = new ImageIcon(this.getClass().getResource("/SEED/icon/goods_sel.gif"));
			ImageIcon sum_nor = new ImageIcon(this.getClass().getResource("/SEED/icon/sum_nor.gif"));
			ImageIcon sum_sel = new ImageIcon(this.getClass().getResource("/SEED/icon/sum_sel.gif"));
			ImageIcon gift_nor = new ImageIcon(this.getClass().getResource("/SEED/icon/goodsStrategy_nor.gif"));
			ImageIcon gift_sel = new ImageIcon(this.getClass().getResource("/SEED/icon/goodsStrategy_sel.gif"));
			
			LabelButton goodsB, sumB, giftB;
			goodsB = new LabelButton(x, y, goods_nor, goods_sel, thisPanel);
			goodsB.addMouseListener(new GoodsInfoManagementButtonListener());
			increaceY();
			
			sumB = new LabelButton(x, y, sum_nor, sum_sel, thisPanel);
			sumB.addMouseListener(new SumStrategyButtonListener());
			increaceY();
			
			giftB = new LabelButton(x, y, gift_nor, gift_sel, thisPanel);
			giftB.addMouseListener(new GoodsStrategyButtonListener());
			increaceY();
			
			this.setLayout(null);
			this.add(goodsB.getLabel());
			this.add(sumB.getLabel());
			this.add(giftB.getLabel());
			
			return y;
		}
	}
	
	protected UpPanel createUpPanel(int width, int height) {
		return new GeneralManagerUpPanel(width, height);
	}
	
	protected DownPanel createDownPanel(int width, int height) {
		return new GeneralManagerDownPanel(width, height);
	}
	
	private class GoodsInfoManagementButtonListener extends MouseAdapter {
		public void mouseClicked(MouseEvent e) {
			RightPanel rp = RightPanelFactory.createGMGoodsManagementRightPanel(frame);
			frame.setRightPanel(rp);
		}
	}

	private class SumStrategyButtonListener extends MouseAdapter {
		public void mouseClicked(MouseEvent e) {
			RightPanel rp = RightPanelFactory.createSumStrategyManagementRightPanel(frame);
			frame.setRightPanel(rp);
		}
	}
	
	private class GoodsStrategyButtonListener extends MouseAdapter {
		public void mouseClicked(MouseEvent e) {
			RightPanel rp = RightPanelFactory.createGoodsStrategyManagemenRightPanel(frame);
			frame.setRightPanel(rp);
		}
	}

}
